<?php
/**
 * @特惠赚、商品模型
 * Author: 小谢
 * Date: 2019-5-9
 */
namespace app\api\model;
use think\Model;
use think\Db;

class Goods extends Model {

	/**
     * @brief 获取首页分类展示数据
     * @param Int $level 分类层级
     * @param Array $fields 数据表字段数组
     * @param Int   $sort_order 排序
     * return mixed
     */
	public function getCategoryList($level,$fields = 'id',$sort_order) {
		 $fields = is_array($fields) ? implode(",", $fields) : $fields;
		 $goods_category =  M('goods_category')->where(['level'=>$level])->field($fields)->order($sort_order)->select();
         if($goods_category) {
              return $goods_category;
         }
         return false;
	}

    /**
     * @brief 获取对应商品列表数据
     * @param Array $condition  查询条件
     * return mixed
     */
    public function getGoodsList($condition) {
         $list = Goods::where($condition)->limit(3)->order('goods_id', 'asc')->select()->toArray();
         if($list) {
             return $list;
         }
         return false;
    }

}
